<template>
    <div :v-loading="loading" class="bg-white p-4 rounded">
        <el-form :model="form" label-width="160px">
            <el-form-item label="物流查询key">
                <div>
                    <el-input v-model="form.ship" placeholder="ship" ></el-input>
                    <small class="mt-1 text-gray-500 flex">用于查询物流信息，接口申请（仅供参考）</small>
                </div>
            </el-form-item>
            <el-form-item>
                <el-button type="primary" size="default" @click="submit">保存</el-button>
            </el-form-item>
        </el-form>
    </div>

</template>

<script setup>
import { ref, reactive } from "vue";
import { getSysConfig, setSysConfig } from "~/api/sysconfig.js";

const loading = ref(false);

const form = reactive({
    "ship": "****已配置****"
})
function getData() {
    loading.value = false;
    getSysConfig()
        .then(res => {
            for (const k in form) {
                form[k] = res[k]
            }
        }).finally(() => {
            loading.value = false;
        })
}
getData();

const submit = () => {
    loading.value = true;
    setSysConfig({
        ...form,
    }).then(res => {
        toast("修改成功");
        getData();
    }).finally(() => {
        loading.value = false;
    })
}

</script>